***Strongholds
gen BiyaVoteShare2018=. , after(Village_Neighborhood)
replace BiyaVoteShare2018=98.8 if Departement==1
replace BiyaVoteShare2018=39.3 if Departement==2
replace BiyaVoteShare2018=52.8 if Departement==3
replace BiyaVoteShare2018=94.1 if Departement==4
replace BiyaVoteShare2018=79.8 if Departement==5
replace BiyaVoteShare2018=51.0 if Departement==6
replace BiyaVoteShare2018=29.6 if Departement==7
replace BiyaVoteShare2018=92.5 if Departement==8
replace BiyaVoteShare2018=71.7 if Departement==9
replace BiyaVoteShare2018=76.5 if Departement==10
replace BiyaVoteShare2018=46.1 if Departement==11
replace BiyaVoteShare2018=34.7 if Departement==12
replace BiyaVoteShare2018=83.1 if Departement==13
replace BiyaVoteShare2018=48.6 if Departement==14
replace BiyaVoteShare2018=28.7 if Departement==15
replace BiyaVoteShare2018=28.7 if Departement==16
replace BiyaVoteShare2018=28.7 if Departement==17
label variable BiyaVoteShare2018 "Percent of the popular vote received by President Biya in each department for the 2018 presidential election"

gen AverageBiyaVoteShare=. , after(BiyaVoteShare2018)
replace AverageBiyaVoteShare=99.5 if Departement==1
replace AverageBiyaVoteShare=41.7 if Departement==2
replace AverageBiyaVoteShare=53.1 if Departement==3
replace AverageBiyaVoteShare=96.0 if Departement==4
replace AverageBiyaVoteShare=77.1 if Departement==5
replace AverageBiyaVoteShare=63.6 if Departement==6
replace AverageBiyaVoteShare=33.3 if Departement==7
replace AverageBiyaVoteShare=94.9 if Departement==8
replace AverageBiyaVoteShare=54.3 if Departement==9
replace AverageBiyaVoteShare=71.8 if Departement==10
replace AverageBiyaVoteShare=36.5 if Departement==11
replace AverageBiyaVoteShare=55.8 if Departement==12
replace AverageBiyaVoteShare=88.1 if Departement==13
replace AverageBiyaVoteShare=52.9 if Departement==14
replace AverageBiyaVoteShare=35.9 if Departement==15
replace AverageBiyaVoteShare=35.4 if Departement==16
replace AverageBiyaVoteShare=35.6 if Departement==17
label variable AverageBiyaVoteShare "Average percent of the popular vote received by President Biya in each department for all contested presidential elections (2018, 2011, 2004, 1992)"

gen OppositionMP2020=. , after(AverageBiyaVoteShare)
replace OppositionMP2020=0 if Arrondissement==3 | Arrondissement==4 | Arrondissement==5 | Arrondissement==6 | Arrondissement==7 | Arrondissement==9 | Arrondissement==11 | Arrondissement==14 | Arrondissement==16 | Arrondissement==17 | Arrondissement==18 | Arrondissement==22 | Arrondissement==25 | Arrondissement==26 | Arrondissement==27 | Arrondissement==28 | Arrondissement==29 | Arrondissement==30 
replace OppositionMP2020=1 if Arrondissement==1 | Arrondissement==2 | Arrondissement==8 | Arrondissement==10 | Arrondissement==12 | Arrondissement==13 | Arrondissement==24 
replace OppositionMP2020=2 if Arrondissement==15 | Arrondissement==19 | Arrondissement==20 | Arrondissement==21 | Arrondissement==23 

label define OppositionMP2020a 0 "RDPC MP" 1 "Split representation" 2 "Opposition MP"
label values OppositionMP2020 OppositionMP2020a
label variable OppositionMP2020 "Department is currently represented by an MP from an opposition party"

gen NumElectionsOppMP=. , after(OppositionMP2020)
replace NumElectionsOppMP=0 if Departement==1
replace NumElectionsOppMP=3 if Departement==2
replace NumElectionsOppMP=1 if Departement==3
replace NumElectionsOppMP=0 if Departement==4
replace NumElectionsOppMP=0 if Departement==5
replace NumElectionsOppMP=0 if Departement==6
replace NumElectionsOppMP=4 if Departement==7
replace NumElectionsOppMP=0 if Departement==8
replace NumElectionsOppMP=0 if Departement==9
replace NumElectionsOppMP=0 if Departement==10
replace NumElectionsOppMP=5 if Departement==11
replace NumElectionsOppMP=3 if Departement==12
replace NumElectionsOppMP=0 if Departement==13
replace NumElectionsOppMP=2 if Departement==14
replace NumElectionsOppMP=4 if Departement==15
replace NumElectionsOppMP=4 if Departement==16
replace NumElectionsOppMP=0 if Departement==17
label variable NumElectionsOppMP "Number of elections in which the department has elected a Deputy from an opposition party (2020, 2013, 2007, 2002, 1997)"

gen NumOppBranchOffice=0 , after(NumElectionsOppMP)
replace NumOppBranchOffice=1 if Arrondissement==1 | Arrondissement==4 | Arrondissement==5 | Arrondissement==10 | Arrondissement==13 | Arrondissement==16 | Arrondissement==19 | Arrondissement==20 | Arrondissement==22 | Arrondissement==27 | Arrondissement==28 | Arrondissement==30
replace NumOppBranchOffice=2 if Arrondissement==2 | Arrondissement==3 | Arrondissement==9 | Arrondissement==12 | Arrondissement==15 | Arrondissement==17 | Arrondissement==21 | Arrondissement==23 | Arrondissement==24 | Arrondissement==29
label variable  NumOppBranchOffice "Number of opposition party branch offices in arrondissement, as reported by at least 30% of respondents sampled in that arrondissement"

gen OppBranchOffice=0 , after(NumOppBranchOffice)
replace OppBranchOffice=1 if Arrondissement==1 | Arrondissement==4 | Arrondissement==5 | Arrondissement==10 | Arrondissement==13 | Arrondissement==16 | Arrondissement==19 | Arrondissement==20 | Arrondissement==22 | Arrondissement==27 | Arrondissement==28 | Arrondissement==30 | Arrondissement==2 | Arrondissement==3 | Arrondissement==9 | Arrondissement==12 | Arrondissement==15 | Arrondissement==17 | Arrondissement==21 | Arrondissement==23 | Arrondissement==24 | Arrondissement==29
label variable  OppBranchOffice "At least one opposition party branch office in arrondissement, as reported by at least 30% of respondents sampled in that arrondissement"

***Partisanship
gen Partisanship=. , before (Q68a)
replace Partisanship=0 if Q65a==0
replace Partisanship=1 if Q65b==1
replace Partisanship=2 if Q65b==2 | Q65b==3 | Q65b==4 | Q65b==5 | Q65b==6 | Q65b==7 | Q65b==8 | Q65b==9 | Q65b==10 | Q65b==11

label define Partisanship1 0 "Nonpartisan" 1 "RDPC Partisan" 2 "Opposition Partisan"
label values Partisanship Partisanship1

gen Nonpartisanship=1 if Partisanship==0 , before (Q68a)
replace Nonpartisanship=0 if Partisanship==1 | Partisanship==2
label define Nonpartisanship 0 "Partisan" 1 "Nonpartisan"
label values Nonpartisanship Nonpartisanship1

gen Partisan=0 if Partisanship==1 , before (Q68a)
replace Partisan=1 if Partisanship==2
label define Partisan1 0 "RDPC Partisan" 1 "Opposition Partisan"
label values Partisan Partisan1
label variable Partisan "Whether the respondent supports the RDPC or an opposition party"

gen OppositionPartisan=0 if Partisanship==0 | Partisanship==1, before (Q68a)
replace OppositionPartisan=1 if Partisanship==2
label define Opposition1 0 "Nonpartisan or RDPC Partisan" 1 "Opposition Partisan"
label values OppositionPartisan Opposition1
label variable OppositionPartisan "Respondent feels close to an opposition party"

gen OppositionPartisan1=. , after (OppositionPartisan)
replace OppositionPartisan1=0 if Partisanship==1
replace OppositionPartisan1=1 if Partisanship==2
label define Opposition2 0 "RDPC Partisan" 1 "Opposition Partisan"
label values OppositionPartisan1 Opposition2
label variable OppositionPartisan1 "Respondent feels close to an opposition party"

gen RulingPartyPartisan=0 if Partisanship==0 | Partisanship==2, before (Q68a)
replace RulingPartyPartisan=1 if Partisanship==1
label define RulingPartyPartisan1 0 "Nonpartisan or Opposition partisan" 1 "Ruling party partisan"
label values RulingPartyPartisan RulingPartyPartisan1
label variable RulingPartyPartisan "Respondent feels close to the ruling party"

gen StrongRulingPartyPartisan=1 if RulingPartyPartisan==1 & Q65c>0, before(Q68a)
replace StrongRulingPartyPartisan=0 if RulingPartyPartisan==1 & Q65c==0
label define StrongRulingPartyPartisan1 0 "Weak Ruling Party Partisan" 1 "Strong Ruling Party Partisan"
label values StrongRulingPartyPartisan StrongRulingPartyPartisan1

gen StrongOppositionPartisan=1 if OppositionPartisan==1 & Q65c>0, before(Q68a)
replace StrongOppositionPartisan=0 if OppositionPartisan==1 & Q65c==0
label define StrongOppositionPartisan 0 "Weak Opposition Party Partisan" 1 "Strong Opposition Party Partisan"
label values StrongOppositionPartisan StrongOppositionPartisan


***Experiments
gen Q132_combined=Q132, after(Q132_1)
replace Q132_combined=Q132_1 if Q132==.
label define Q132_combineda 0 "No" 1 "Yes"
label values Q132_combined Q132_combineda

gen Q132_treatment=., after(Q132_combined)
replace Q132_treatment=0 if Q132==0 | Q132==1
replace Q132_treatment=1 if Q132_1==0 | Q132_1==1
label define Q132_treatmenta 0 "Control Group" 1 "Treatment Group"
label values Q132_treatment Q132_treatmenta

gen Q133_combined=Q133, after(Q133_1)
replace Q133_combined=Q133_1 if Q133==.
label values Q133_combined Q132_combineda

gen Q133_treatment=., after(Q133_combined)
replace Q133_treatment=0 if Q133==0 | Q133==1
replace Q133_treatment=1 if Q133_1==0 | Q133_1==1
label values Q133_treatment Q132_treatmenta

gen Q134_combined=Q134, after(Q134_1)
replace Q134_combined=Q134_1 if Q134==.
label values Q134_combined Q132_combineda

gen Q134_treatment=., after(Q134_combined)
replace Q134_treatment=0 if Q134==0 | Q134==1
replace Q134_treatment=1 if Q134_1==0 | Q134_1==1
label values Q134_treatment Q132_treatmenta

gen Q135_combined=Q135, after(Q135_1)
replace Q135_combined=Q135_1 if Q135==.
label values Q135_combined Q132_combineda

gen Q135_treatment=., after(Q135_combined)
replace Q135_treatment=0 if Q135==0 | Q135==1
replace Q135_treatment=1 if Q135_1==0 | Q135_1==1
label values Q135_treatment Q132_treatmenta

***Awarness of SCT
gen heard_SCT=.
re;lace heard_SCT=1 if Q95==1 | Q95==2
replace heard_SCT=0 if Q95==0
label define heard_SCTa 0 "Never Heard of Tribunal" heard_SCTa 1 "Heard of Tribunal"
label values heard_SCT heard_SCTa

***Trust in President Biya
gen TrustBiyaDichotomous=.
replace TrustBiyaDichotomous=0 if Q100==0 | Q100==1
replace TrustBiyaDichotomous=1 if Q100==2 | Q100==3
label define Trust 0 "Low Trust" 1 "High Trust"
label values TrustBiyaDichotomous Trust


///OTHER VARIABLES
****SES (this does not include education)
factor Q122a Q122b Q122c Q122d Q122e Q122f Q122g Q122h Q122i Q122j Q125 Q126 Q128 Q129 Q130, pcf
rotate
predict SES_Factor
order SES_Factor,  after(Q130)

****SES (INCLUDING EDUCATION)
factor Education Q122a Q122b Q122c Q122d Q122e Q122f Q122g Q122h Q122i Q122j Q125 Q126 Q128 Q129 Q130, pcf
rotate
predict SES_Factor2
order SES_Factor2,  after(SES_Factor)

***Political Knowledge--->0.1287736 is the median
factor Q90 Q91 Q93 Q95, pcf
rotate
predict PolKnowledge_Factor
order PolKnowledge_Factor,  after(Q95)

***Political Knowledge WITHOUT "BOASTERS"--->0.6458725 is the median
factor Q90 Q91 Q93 Q95 if Q92==0 & Q94==0, pcf
rotate
predict PolKnowledge_Factor_NoBoaster
order PolKnowledge_Factor_NoBoaster,  after(Q95)

*****Regime Trust
factor Q96 Q97 Q98 Q100, pcf
rotate
predict RegimeTrust_Factor
order RegimeTrust_Factor,  after(Q101)

******News Consumption
factor Radio Television Newspapers SocialMedia, pcf
rotate
predict News_Factor
order News_Factor,  after(Q24b)

gen RadioGov= Radio*radiogovt, after(radiogovt)
gen TVGov= Television*tvgovt, after(tvgovt)
gen NewspapersGov= Newspapers*newspapergovt, after(newspapergovt)

factor RadioGov TVGov NewspapersGov, pcf
rotate
predict GovtNews_Factor
order GovtNews_Factor,  after(News_Factor2)

gen RadioInd= Radio*radioind, after(radioind)
gen TVInd= Television*tvind, after(tvind)
gen NewspapersInd= Newspapers*newspaperind, after(newspaperind)

factor RadioInd TVInd NewspapersInd, pcf
rotate
predict IndNews_Factor
order IndNews_Factor,  after(GovtNews_Factor)

gen RadioInter= Radio*radiointer, after(radiointer)
gen TVInter= Television*tvinter, after(tvinter)
gen NewspapersInter= Newspapers*newspaperinter, after(newspaperinter)

factor RadioInter TVInter NewspapersInter, pcf
rotate
predict InterNews_Factor
order InterNews_Factor,  after(IndNews_Factor)

gen PureGovtNews_Factor= GovtNews_Factor-IndNews_Factor-InterNews_Factor, after(InterNews_Factor)

*****Beliefs about Freedom
factor Q102 Q103 Q104, pcf
rotate
predict Freedom_Factor
order Freedom_Factor,  after(Q104)

****alternative News consumption
factor Radio Television Newspapers, pcf
rotate
predict News_Factor2
order News_Factor2, after(News_Factor)

***political activism
factor Q80 Q81 Q82 Q83 Q84, pcf
rotate
predict Activism_Factor
order Activism_Factor,after(Q84)

****Reason for nonpartisanship
factor Q67a Q67b Q67f Q67g, pcf
rotate
predict Q67_Factor
order Q67_Factor,after(Q67i)

***rescale indexes to 0 to 10
sum Activism_Factor, meanonly
gen Activism_Factor2=( Activism_Factor - r(min) ) / ( r(max)-r(min ) ) * 10
sum News_Factor2, meanonly
gen News_Factor2a=( News_Factor2 - r(min) ) / ( r(max)-r(min ) ) * 10
sum RegimeTrust_Factor, meanonly
gen RegimeTrust_Factor2=( RegimeTrust_Factor - r(min) ) / ( r(max)-r(min ) ) * 10
sum Freedom_Factor, meanonly
gen Freedom_Factor2=( Freedom_Factor - r(min) ) / ( r(max)-r(min ) ) * 10

sum Q67_Factor, meanonly
gen Q67_Factor2=( Q67_Factor - r(min) ) / ( r(max)-r(min ) ) * 10 , after(Q67_Factor)
sum GovtNews_Factor, meanonly
gen GovtNews_Factor2=( GovtNews_Factor - r(min) ) / ( r(max)-r(min ) ) * 10 , after(GovtNews_Factor)
sum PureGovtNews_Factor, meanonly
gen PureGovtNews_Factor2=( PureGovtNews_Factor - r(min) ) / ( r(max)-r(min ) ) * 10 , after(PureGovtNews_Factor)

*****News source
merge 1:1 SbjNum using "/Users/NatalieLetsa/Google Drive/Writing/Autocracy Book Manuscript/Fieldwork/Survey 2021/Data/CLEANED & NONRESPONSE REMOVED Original Data Set.dta", keepusing(radiogovt radioind radiointer RadioGuinée tvgovt tvind tvinter newspapergovt newspaperind newspaperinter)
drop(_merge)
order radiogovt radioind radiointer RadioGuinée, after(Q21b)
order tvgovt tvind tvinter, after(Q22b)
order newspapergovt newspaperind newspaperinter, after(Q23b)

***Sophistication and Trust 
gen Sophistication=Q28*Q82
gen SophisticationDichotomous=.
replace SophisticationDichotomous=0 if Sophistication<2
replace SophisticationDichotomous=1 if Sophistication>=2
label define Soph 0 "Low Soph." 1 "High Soph."
label values SophisticationDichotomous Soph







